Field of the Invention
An aspect of the embodiments relates to a calculation device, a calculation method, a communication apparatus, and a storage medium and more particularly to a technique for efficiently performing checksum calculation.
Description of the Related Art
In a communication field, checksum calculation might be necessary. A checksum is information used to detect an error. In transmission control protocol (TCP) checksum calculation during TCP/Internet protocol (IP) communication, which is widely used for the Internet today, all payload data in TCP packets are to be calculated. Regardless of whether the TCP checksum calculation is performed by a central processing unit (CPU) based on a computer program or by hardware, all the payload data are to be transmitted to a calculation unit.
In Japanese Patent Laid-Open No. 6-78024, a configuration relating to a network adapter capable of performing checksum calculation is described. With the configuration, checksum unprocessed packets stored in a storage device and checksum control information are transmitted to the network adapter. The network adapter performs checksum calculation on the checksum unprocessed packets on the basis of the checksum control information and transmits complete packets to an interface and then to a network.
In Japanese Patent Laid-Open No. 2006-303765, hardware achieves IP checksums and TCP checksums in transmission of TCP/IP packets. With this configuration, checksum calculation is performed while the TCP/IP packets are being transmitted from a direct memory access (DMA) processing unit to a media access control (MAC) bridge circuit.
A transmitter that reads checksum unprocessed packets from a memory, performs checksum calculation, and transmits complete packets to an interface has the following functions:    (1) a process for reading the checksum unprocessed packets from the memory;    (2) a process for analyzing headers of the checksum unprocessed packets;    (3) a process for calculating checksums on the basis of results of the analysis;    (4) a process for overwriting the checksum unprocessed packets with results of the checksum calculation; and    (5) a process for transmitting complete packets obtained as a result of the overwriting process to the interface.Transmission of data on which the transmitter having the above functions has performed checksum calculation poses the following two situations.
The first situation arises from characteristics of communication in which checksums are used. A checksum is added to a header, that is, at a top, of each packet. If checksum calculation is to be performed up to an end of a packet, therefore, data from a position at which a checksum is to be written to the end of the packet is to be temporarily stored in the transmitter. This means that when the transmitter performs checksum calculation on a packet larger than maximum transmission unit (MTU) size, the transmitter would have a large buffer, which is costly.
The second situation arises when encrypted communication is performed. If packets prepared in the memory are encrypted packets, headers to be analyzed and data to be calculated might also be encrypted. In this case, even if a communication protocol that requires checksum calculation is employed, the transmitter might not be able to correctly perform checksum calculation between the memory and the interface. If the transmitter performs checksum calculation, the packets might be destroyed.
The present invention provides a technique for efficiently performing checksum calculation in various communication methods.